home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / FS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  30KB  |  901 lines

  1. #ifndef _LINUX_FS_H
  2. #define _LINUX_FS_H
  3.  
  4. /*
  5.  * This file has definitions for some important file table
  6.  * structures etc.
  7.  */
  8.  
  9. #include <linux/config.h>
  10. #include <linux/linkage.h>
  11. #include <linux/limits.h>
  12. #include <linux/wait.h>
  13. #include <linux/types.h>
  14. #include <linux/vfs.h>
  15. #include <linux/net.h>
  16. #include <linux/kdev_t.h>
  17. #include <linux/ioctl.h>
  18. #include <linux/list.h>
  19. #include <linux/dcache.h>
  20. #include <linux/stat.h>
  21.  
  22. #include <asm/atomic.h>
  23. #include <asm/bitops.h>
  24. #include <asm/cache.h>
  25.  
  26. struct poll_table_struct;
  27.  
  28.  
  29. /*
  30.  * It's silly to have NR_OPEN bigger than NR_FILE, but I'll fix
  31.  * that later. Anyway, now the file code is no longer dependent
  32.  * on bitmaps in unsigned longs, but uses the new fd_set structure..
  33.  *
  34.  * Some programs (notably those using select()) may have to be 
  35.  * recompiled to take full advantage of the new limits..
  36.  */
  37.  
  38. /* Fixed constants first: */
  39. #undef NR_OPEN
  40. #define NR_OPEN 1024
  41.  
  42. #define BLOCK_SIZE_BITS 10
  43. #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
  44.  
  45. /* And dynamically-tunable limits and defaults: */
  46. extern int max_inodes;
  47. extern int max_files, nr_files, nr_free_files;
  48. extern int max_super_blocks, nr_super_blocks;
  49.  
  50. #define NR_FILE  4096    /* this can well be larger on a larger system */
  51. #define NR_RESERVED_FILES 10 /* reserved for root */
  52. #define NR_SUPER 256
  53.  
  54. #define MAY_EXEC 1
  55. #define MAY_WRITE 2
  56. #define MAY_READ 4
  57.  
  58. #define FMODE_READ 1
  59. #define FMODE_WRITE 2
  60.  
  61. #define READ 0
  62. #define WRITE 1
  63. #define READA 2        /* read-ahead  - don't block if no resources */
  64. #define WRITEA 3    /* write-ahead - don't block if no resources */
  65.  
  66. #ifndef NULL
  67. #define NULL ((void *) 0)
  68. #endif
  69.  
  70. #define NIL_FILP    ((struct file *)0)
  71. #define SEL_IN        1
  72. #define SEL_OUT        2
  73. #define SEL_EX        4
  74.  
  75. /* public flags for file_system_type */
  76. #define FS_REQUIRES_DEV 1 
  77. #define FS_NO_DCACHE    2 /* Only dcache the necessary things. */
  78. #define FS_NO_PRELIM    4 /* prevent preloading of dentries, even if
  79.                * FS_NO_DCACHE is not set.
  80.                */
  81. #define FS_IBASKET      8 /* FS does callback to free_ibasket() if space gets low. */
  82.  
  83. /*
  84.  * These are the fs-independent mount-flags: up to 16 flags are supported
  85.  */
  86. #define MS_RDONLY     1    /* Mount read-only */
  87. #define MS_NOSUID     2    /* Ignore suid and sgid bits */
  88. #define MS_NODEV     4    /* Disallow access to device special files */
  89. #define MS_NOEXEC     8    /* Disallow program execution */
  90. #define MS_SYNCHRONOUS    16    /* Writes are synced at once */
  91. #define MS_REMOUNT    32    /* Alter flags of a mounted FS */
  92. #define MS_MANDLOCK    64    /* Allow mandatory locks on an FS */
  93. #define S_QUOTA        128    /* Quota initialized for file/directory/symlink */
  94. #define S_APPEND    256    /* Append-only file */
  95. #define S_IMMUTABLE    512    /* Immutable file */
  96. #define MS_NOATIME    1024    /* Do not update access times. */
  97. #define MS_NODIRATIME   2048    /* Do not update directory access times */
  98.  
  99. #define MS_ODD_RENAME   32768    /* Temporary stuff; will go away as soon
  100.                   * as nfs_rename() will be cleaned up
  101.                   */
  102.  
  103. /*
  104.  * Flags that can be altered by MS_REMOUNT
  105.  */
  106. #define MS_RMT_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
  107.  
  108. /*
  109.  * Magic mount flag number. Has to be or-ed to the flag values.
  110.  */
  111. #define MS_MGC_VAL 0xC0ED0000    /* magic flag number to indicate "new" flags */
  112. #define MS_MGC_MSK 0xffff0000    /* magic flag number mask */
  113.  
  114. /*
  115.  * Note that read-only etc flags are inode-specific: setting some file-system
  116.  * flags just means all the inodes inherit those flags by default. It might be
  117.  * possible to override it selectively if you really wanted to with some
  118.  * ioctl() that is not currently implemented.
  119.  *
  120.  * Exception: MS_RDONLY is always applied to the entire file system.
  121.  *
  122.  * Unfortunately, it is possible to change a filesystems flags with it mounted
  123.  * with files in use.  This means that all of the inodes will not have their
  124.  * i_flags updated.  Hence, i_flags no longer inherit the superblock mount
  125.  * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
  126.  */
  127. #define __IS_FLG(inode,flg) (((inode)->i_sb && (inode)->i_sb->s_flags & (flg)) \
  128.                 || (inode)->i_flags & (flg))
  129.  
  130. #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
  131. #define IS_NOSUID(inode)    __IS_FLG(inode, MS_NOSUID)
  132. #define IS_NODEV(inode)        __IS_FLG(inode, MS_NODEV)
  133. #define IS_NOEXEC(inode)    __IS_FLG(inode, MS_NOEXEC)
  134. #define IS_SYNC(inode)        __IS_FLG(inode, MS_SYNCHRONOUS)
  135. #define IS_MANDLOCK(inode)    __IS_FLG(inode, MS_MANDLOCK)
  136.  
  137. #define IS_QUOTAINIT(inode)    ((inode)->i_flags & S_QUOTA)
  138. #define IS_APPEND(inode)    ((inode)->i_flags & S_APPEND)
  139. #define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
  140. #define IS_NOATIME(inode)    __IS_FLG(inode, MS_NOATIME)
  141. #define IS_NODIRATIME(inode)    __IS_FLG(inode, MS_NODIRATIME)
  142.  
  143. /* the read-only stuff doesn't really belong here, but any other place is
  144.    probably as bad and I don't want to create yet another include file. */
  145.  
  146. #define BLKROSET   _IO(0x12,93)    /* set device read-only (0 = read-write) */
  147. #define BLKROGET   _IO(0x12,94)    /* get read-only status (0 = read_write) */
  148. #define BLKRRPART  _IO(0x12,95)    /* re-read partition table */
  149. #define BLKGETSIZE _IO(0x12,96)    /* return device size */
  150. #define BLKFLSBUF  _IO(0x12,97)    /* flush buffer cache */
  151. #define BLKRASET   _IO(0x12,98)    /* Set read ahead for block device */
  152. #define BLKRAGET   _IO(0x12,99)    /* get current read ahead setting */
  153. #define BLKFRASET  _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
  154. #define BLKFRAGET  _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
  155. #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
  156. #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
  157. #define BLKSSZGET  _IO(0x12,104)/* get block device sector size (reserved for) */
  158.  
  159. #define BMAP_IOCTL 1        /* obsolete - kept for compatibility */
  160. #define FIBMAP       _IO(0x00,1)    /* bmap access */
  161. #define FIGETBSZ   _IO(0x00,2)    /* get the block size used for bmap */
  162.  
  163. #ifdef __KERNEL__
  164.  
  165. #include <asm/semaphore.h>
  166. #include <asm/byteorder.h>
  167. #include <asm/bitops.h>
  168.  
  169. extern void update_atime (struct inode *inode);
  170. #define UPDATE_ATIME(inode) update_atime (inode)
  171.  
  172. extern void buffer_init(void);
  173. extern void inode_init(void);
  174. extern void file_table_init(void);
  175. extern void dcache_init(void);
  176.  
  177. typedef char buffer_block[BLOCK_SIZE];
  178.  
  179. /* bh state bits */
  180. #define BH_Uptodate    0    /* 1 if the buffer contains valid data */
  181. #define BH_Dirty    1    /* 1 if the buffer is dirty */
  182. #define BH_Lock        2    /* 1 if the buffer is locked */
  183. #define BH_Req        3    /* 0 if the buffer has been invalidated */
  184. #define BH_Protected    6    /* 1 if the buffer is protected */
  185.  
  186. /*
  187.  * Try to keep the most commonly used fields in single cache lines (16
  188.  * bytes) to improve performance.  This ordering should be
  189.  * particularly beneficial on 32-bit processors.
  190.  * 
  191.  * We use the first 16 bytes for the data which is used in searches
  192.  * over the block hash lists (ie. getblk(), find_buffer() and
  193.  * friends).
  194.  * 
  195.  * The second 16 bytes we use for lru buffer scans, as used by
  196.  * sync_buffers() and refill_freelist().  -- sct
  197.  */
  198. struct buffer_head {
  199.     /* First cache line: */
  200.     struct buffer_head * b_next;    /* Hash queue list */
  201.     unsigned long b_blocknr;    /* block number */
  202.     unsigned long b_size;        /* block size */
  203.     kdev_t b_dev;            /* device (B_FREE = free) */
  204.     kdev_t b_rdev;            /* Real device */
  205.     unsigned long b_rsector;    /* Real buffer location on disk */
  206.     struct buffer_head * b_this_page;    /* circular list of buffers in one page */
  207.     unsigned long b_state;        /* buffer state bitmap (see above) */
  208.     struct buffer_head * b_next_free;
  209.     unsigned int b_count;        /* users using this block */
  210.  
  211.     /* Non-performance-critical data follows. */
  212.     char * b_data;            /* pointer to data block (1024 bytes) */
  213.     unsigned int b_list;        /* List that this buffer appears */
  214.     unsigned long b_flushtime;      /* Time when this (dirty) buffer
  215.                      * should be written */
  216.     struct wait_queue * b_wait;
  217.     struct buffer_head ** b_pprev;        /* doubly linked list of hash-queue */
  218.     struct buffer_head * b_prev_free;    /* doubly linked list of buffers */
  219.     struct buffer_head * b_reqnext;        /* request queue */
  220.  
  221.     /*
  222.      * I/O completion
  223.      */
  224.     void (*b_end_io)(struct buffer_head *bh, int uptodate);
  225.     void *b_dev_id;
  226. };
  227.  
  228. typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
  229. void init_buffer(struct buffer_head *bh, kdev_t dev, int block,
  230.          bh_end_io_t *handler, void *dev_id);
  231.  
  232. static inline int buffer_uptodate(struct buffer_head * bh)
  233. {
  234.     return test_bit(BH_Uptodate, &bh->b_state);
  235. }    
  236.  
  237. static inline int buffer_dirty(struct buffer_head * bh)
  238. {
  239.     return test_bit(BH_Dirty, &bh->b_state);
  240. }
  241.  
  242. static inline int buffer_locked(struct buffer_head * bh)
  243. {
  244.     return test_bit(BH_Lock, &bh->b_state);
  245. }
  246.  
  247. static inline int buffer_req(struct buffer_head * bh)
  248. {
  249.     return test_bit(BH_Req, &bh->b_state);
  250. }
  251.  
  252. static inline int buffer_protected(struct buffer_head * bh)
  253. {
  254.     return test_bit(BH_Protected, &bh->b_state);
  255. }
  256.  
  257. /*
  258.  * Deprecated - we don't keep per-buffer reference flags
  259.  * any more.
  260.  *
  261.  * We _could_ try to update the page reference, but that
  262.  * doesn't seem to really be worth it either. If we did,
  263.  * it would look something like this:
  264.  *
  265.  *    #define buffer_page(bh)        (mem_map + MAP_NR((bh)->b_data))
  266.  *    #define touch_buffer(bh)    set_bit(PG_referenced, &buffer_page(bh)->flags)
  267.  */
  268. #define touch_buffer(bh)    do { } while (0)
  269.  
  270. #include <linux/pipe_fs_i.h>
  271. #include <linux/minix_fs_i.h>
  272. #include <linux/ext2_fs_i.h>
  273. #include <linux/hpfs_fs_i.h>
  274. #include <linux/ntfs_fs_i.h>
  275. #include <linux/msdos_fs_i.h>
  276. #include <linux/umsdos_fs_i.h>
  277. #include <linux/iso_fs_i.h>
  278. #include <linux/nfs_fs_i.h>
  279. #include <linux/sysv_fs_i.h>
  280. #include <linux/affs_fs_i.h>
  281. #include <linux/ufs_fs_i.h>
  282. #include <linux/coda_fs_i.h>
  283. #include <linux/romfs_fs_i.h>
  284. #include <linux/smb_fs_i.h>
  285. #include <linux/hfs_fs_i.h>
  286. #include <linux/adfs_fs_i.h>
  287. #include <linux/qnx4_fs_i.h>
  288.  
  289. /*
  290.  * Attribute flags.  These should be or-ed together to figure out what
  291.  * has been changed!
  292.  */
  293. #define ATTR_MODE    1
  294. #define ATTR_UID    2
  295. #define ATTR_GID    4
  296. #define ATTR_SIZE    8
  297. #define ATTR_ATIME    16
  298. #define ATTR_MTIME    32
  299. #define ATTR_CTIME    64
  300. #define ATTR_ATIME_SET    128
  301. #define ATTR_MTIME_SET    256
  302. #define ATTR_FORCE    512    /* Not a change, but a change it */
  303. #define ATTR_ATTR_FLAG    1024
  304.  
  305. /*
  306.  * This is the Inode Attributes structure, used for notify_change().  It
  307.  * uses the above definitions as flags, to know which values have changed.
  308.  * Also, in this manner, a Filesystem can look at only the values it cares
  309.  * about.  Basically, these are the attributes that the VFS layer can
  310.  * request to change from the FS layer.
  311.  *
  312.  * Derek Atkins <warlord@MIT.EDU> 94-10-20
  313.  */
  314. struct iattr {
  315.     unsigned int    ia_valid;
  316.     umode_t        ia_mode;
  317.     uid_t        ia_uid;
  318.     gid_t        ia_gid;
  319.     off_t        ia_size;
  320.     time_t        ia_atime;
  321.     time_t        ia_mtime;
  322.     time_t        ia_ctime;
  323.     unsigned int    ia_attr_flags;
  324. };
  325.  
  326. /*
  327.  * This is the inode attributes flag definitions
  328.  */
  329. #define ATTR_FLAG_SYNCRONOUS    1     /* Syncronous write */
  330. #define ATTR_FLAG_NOATIME    2     /* Don't update atime */
  331. #define ATTR_FLAG_APPEND    4     /* Append-only file */
  332. #define ATTR_FLAG_IMMUTABLE    8     /* Immutable file */
  333. #define ATTR_FLAG_NODIRATIME    16     /* Don't update atime for directory */
  334.  
  335. /*
  336.  * Includes for diskquotas and mount structures.
  337.  */
  338. #include <linux/quota.h>
  339. #include <linux/mount.h>
  340.  
  341. struct inode {
  342.     struct list_head    i_hash;
  343.     struct list_head    i_list;
  344.     struct list_head    i_dentry;
  345.  
  346.     unsigned long        i_ino;
  347.     unsigned int        i_count;
  348.     kdev_t            i_dev;
  349.     umode_t            i_mode;
  350.     nlink_t            i_nlink;
  351.     uid_t            i_uid;
  352.     gid_t            i_gid;
  353.     kdev_t            i_rdev;
  354.     off_t            i_size;
  355.     time_t            i_atime;
  356.     time_t            i_mtime;
  357.     time_t            i_ctime;
  358.     unsigned long        i_blksize;
  359.     unsigned long        i_blocks;
  360.     unsigned long        i_version;
  361.     unsigned long        i_nrpages;
  362.     struct semaphore    i_sem;
  363.     struct semaphore    i_atomic_write;
  364.     struct inode_operations    *i_op;
  365.     struct super_block    *i_sb;
  366.     struct wait_queue    *i_wait;
  367.     struct file_lock    *i_flock;
  368.     struct vm_area_struct    *i_mmap;
  369.     struct page        *i_pages;
  370.     struct dquot        *i_dquot[MAXQUOTAS];
  371.  
  372.     unsigned long        i_state;
  373.  
  374.     unsigned int        i_flags;
  375.     unsigned char        i_pipe;
  376.     unsigned char        i_sock;
  377.  
  378.     int            i_writecount;
  379.     unsigned int        i_attr_flags;
  380.     __u32            i_generation;
  381.     union {
  382.         struct pipe_inode_info        pipe_i;
  383.         struct minix_inode_info        minix_i;
  384.         struct ext2_inode_info        ext2_i;
  385.         struct hpfs_inode_info        hpfs_i;
  386.         struct ntfs_inode_info          ntfs_i;
  387.         struct msdos_inode_info        msdos_i;
  388.         struct umsdos_inode_info    umsdos_i;
  389.         struct iso_inode_info        isofs_i;
  390.         struct nfs_inode_info        nfs_i;
  391.         struct sysv_inode_info        sysv_i;
  392.         struct affs_inode_info        affs_i;
  393.         struct ufs_inode_info        ufs_i;
  394.         struct romfs_inode_info        romfs_i;
  395.         struct coda_inode_info        coda_i;
  396.         struct smb_inode_info        smbfs_i;
  397.         struct hfs_inode_info        hfs_i;
  398.         struct adfs_inode_info        adfs_i;
  399.         struct qnx4_inode_info        qnx4_i;       
  400.         struct socket            socket_i;
  401.         void                *generic_ip;
  402.     } u;
  403. };
  404.  
  405. /* Inode state bits.. */
  406. #define I_DIRTY        1
  407. #define I_LOCK        2
  408. #define I_FREEING    4
  409.  
  410. extern void __mark_inode_dirty(struct inode *);
  411. static inline void mark_inode_dirty(struct inode *inode)
  412. {
  413.     if (!(inode->i_state & I_DIRTY))
  414.         __mark_inode_dirty(inode);
  415. }
  416.  
  417. struct fown_struct {
  418.     int pid;        /* pid or -pgrp where SIGIO should be sent */
  419.     uid_t uid, euid;    /* uid/euid of process setting the owner */
  420.     int signum;        /* posix.1b rt signal to be delivered on IO */
  421. };
  422.  
  423. struct file {
  424.     struct file        *f_next, **f_pprev;
  425.     struct dentry        *f_dentry;
  426.     struct file_operations    *f_op;
  427.     mode_t            f_mode;
  428.     loff_t            f_pos;
  429.     unsigned int         f_count, f_flags;
  430.     unsigned long         f_reada, f_ramax, f_raend, f_ralen, f_rawin;
  431.     struct fown_struct    f_owner;
  432.     unsigned int        f_uid, f_gid;
  433.     int            f_error;
  434.  
  435.     unsigned long        f_version;
  436.  
  437.     /* needed for tty driver, and maybe others */
  438.     void            *private_data;
  439. };
  440.  
  441. extern int init_private_file(struct file *, struct dentry *, int);
  442.  
  443. #define FL_POSIX    1
  444. #define FL_FLOCK    2
  445. #define FL_BROKEN    4    /* broken flock() emulation */
  446. #define FL_ACCESS    8    /* for processes suspended by mandatory locking */
  447. #define FL_LOCKD    16    /* lock held by rpc.lockd */
  448.  
  449. /*
  450.  * The POSIX file lock owner is determined by
  451.  * the "struct files_struct" in the thread group
  452.  * (or NULL for no owner - BSD locks).
  453.  *
  454.  * Lockd stuffs a "host" pointer into this.
  455.  */
  456. typedef struct files_struct *fl_owner_t;
  457.  
  458. struct file_lock {
  459.     struct file_lock *fl_next;    /* singly linked list for this inode  */
  460.     struct file_lock *fl_nextlink;    /* doubly linked list of all locks */
  461.     struct file_lock *fl_prevlink;    /* used to simplify lock removal */
  462.     struct file_lock *fl_nextblock; /* circular list of blocked processes */
  463.     struct file_lock *fl_prevblock;
  464.     fl_owner_t fl_owner;
  465.     unsigned int fl_pid;
  466.     struct wait_queue *fl_wait;
  467.     struct file *fl_file;
  468.     unsigned char fl_flags;
  469.     unsigned char fl_type;
  470.     off_t fl_start;
  471.     off_t fl_end;
  472.  
  473.     void (*fl_notify)(struct file_lock *);    /* unblock callback */
  474.  
  475.     union {
  476.         struct nfs_lock_info    nfs_fl;
  477.     } fl_u;
  478. };
  479.  
  480. extern struct file_lock            *file_lock_table;
  481.  
  482. #include <linux/fcntl.h>
  483.  
  484. extern int fcntl_getlk(unsigned int fd, struct flock *l);
  485. extern int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l);
  486.  
  487. /* fs/locks.c */
  488. extern void locks_remove_posix(struct file *, fl_owner_t id);
  489. extern void locks_remove_flock(struct file *);
  490. extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
  491. extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
  492. extern void posix_block_lock(struct file_lock *, struct file_lock *);
  493. extern void posix_unblock_lock(struct file_lock *);
  494.  
  495. #include <linux/stat.h>
  496.  
  497. struct fasync_struct {
  498.     int    magic;
  499.     int    fa_fd;
  500.     struct fasync_struct    *fa_next; /* singly linked list */
  501.     struct file         *fa_file;
  502. };
  503.  
  504. #define FASYNC_MAGIC 0x4601
  505.  
  506. extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
  507.  
  508. #include <linux/minix_fs_sb.h>
  509. #include <linux/ext2_fs_sb.h>
  510. #include <linux/hpfs_fs_sb.h>
  511. #include <linux/ntfs_fs_sb.h>
  512. #include <linux/msdos_fs_sb.h>
  513. #include <linux/iso_fs_sb.h>
  514. #include <linux/nfs_fs_sb.h>
  515. #include <linux/sysv_fs_sb.h>
  516. #include <linux/affs_fs_sb.h>
  517. #include <linux/ufs_fs_sb.h>
  518. #include <linux/romfs_fs_sb.h>
  519. #include <linux/smb_fs_sb.h>
  520. #include <linux/hfs_fs_sb.h>
  521. #include <linux/adfs_fs_sb.h>
  522. #include <linux/qnx4_fs_sb.h>
  523.  
  524. extern struct list_head super_blocks;
  525.  
  526. #define sb_entry(list)    list_entry((list), struct super_block, s_list)
  527. struct super_block {
  528.     struct list_head    s_list;        /* Keep this first */
  529.     kdev_t            s_dev;
  530.     unsigned long        s_blocksize;
  531.     unsigned char        s_blocksize_bits;
  532.     unsigned char        s_lock;
  533.     unsigned char        s_rd_only;
  534.     unsigned char        s_dirt;
  535.     struct file_system_type    *s_type;
  536.     struct super_operations    *s_op;
  537.     struct dquot_operations    *dq_op;
  538.     unsigned long        s_flags;
  539.     unsigned long        s_magic;
  540.     unsigned long        s_time;
  541.     struct dentry        *s_root;
  542.     struct wait_queue    *s_wait;
  543.  
  544.     struct inode        *s_ibasket;
  545.     short int        s_ibasket_count;
  546.     short int        s_ibasket_max;
  547.     struct list_head    s_dirty;    /* dirty inodes */
  548.  
  549.     union {
  550.         struct minix_sb_info    minix_sb;
  551.         struct ext2_sb_info    ext2_sb;
  552.         struct hpfs_sb_info    hpfs_sb;
  553.         struct ntfs_sb_info     ntfs_sb;
  554.         struct msdos_sb_info    msdos_sb;
  555.         struct isofs_sb_info    isofs_sb;
  556.         struct nfs_sb_info    nfs_sb;
  557.         struct sysv_sb_info    sysv_sb;
  558.         struct affs_sb_info    affs_sb;
  559.         struct ufs_sb_info    ufs_sb;
  560.         struct romfs_sb_info    romfs_sb;
  561.         struct smb_sb_info    smbfs_sb;
  562.         struct hfs_sb_info    hfs_sb;
  563.         struct adfs_sb_info    adfs_sb;
  564.         struct qnx4_sb_info    qnx4_sb;       
  565.         void            *generic_sbp;
  566.     } u;
  567.     /*
  568.      * The next field is for VFS *only*. No filesystems have any business
  569.      * even looking at it. You had been warned.
  570.      */
  571.     struct semaphore s_vfs_rename_sem;    /* Kludge */
  572. };
  573.  
  574. /*
  575.  * VFS helper functions..
  576.  */
  577. extern int vfs_rmdir(struct inode *, struct dentry *);
  578. extern int vfs_unlink(struct inode *, struct dentry *);
  579. extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
  580.  
  581. /*
  582.  * This is the "filldir" function type, used by readdir() to let
  583.  * the kernel specify what kind of dirent layout it wants to have.
  584.  * This allows the kernel to read directories into kernel space or
  585.  * to have different dirent layouts depending on the binary type.
  586.  */
  587. typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
  588.     
  589. struct file_operations {
  590.     loff_t (*llseek) (struct file *, loff_t, int);
  591.     ssize_t (*read) (struct file *, char *, size_t, loff_t *);
  592.     ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
  593.     int (*readdir) (struct file *, void *, filldir_t);
  594.     unsigned int (*poll) (struct file *, struct poll_table_struct *);
  595.     int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
  596.     int (*mmap) (struct file *, struct vm_area_struct *);
  597.     int (*open) (struct inode *, struct file *);
  598.     int (*flush) (struct file *);
  599.     int (*release) (struct inode *, struct file *);
  600.     int (*fsync) (struct file *, struct dentry *);
  601.     int (*fasync) (int, struct file *, int);
  602.     int (*check_media_change) (kdev_t dev);
  603.     int (*revalidate) (kdev_t dev);
  604.     int (*lock) (struct file *, int, struct file_lock *);
  605. };
  606.  
  607. struct inode_operations {
  608.     struct file_operations * default_file_ops;
  609.     int (*create) (struct inode *,struct dentry *,int);
  610.     int (*lookup) (struct inode *,struct dentry *);
  611.     int (*link) (struct dentry *,struct inode *,struct dentry *);
  612.     int (*unlink) (struct inode *,struct dentry *);
  613.     int (*symlink) (struct inode *,struct dentry *,const char *);
  614.     int (*mkdir) (struct inode *,struct dentry *,int);
  615.     int (*rmdir) (struct inode *,struct dentry *);
  616.     int (*mknod) (struct inode *,struct dentry *,int,int);
  617.     int (*rename) (struct inode *, struct dentry *,
  618.             struct inode *, struct dentry *);
  619.     int (*readlink) (struct dentry *, char *,int);
  620.     struct dentry * (*follow_link) (struct dentry *, struct dentry *, unsigned int);
  621.     int (*readpage) (struct file *, struct page *);
  622.     int (*writepage) (struct file *, struct page *);
  623.     int (*bmap) (struct inode *,int);
  624.     void (*truncate) (struct inode *);
  625.     int (*permission) (struct inode *, int);
  626.     int (*smap) (struct inode *,int);
  627.     int (*updatepage) (struct file *, struct page *, unsigned long, unsigned int, int);
  628.     int (*revalidate) (struct dentry *);
  629. };
  630.  
  631. struct super_operations {
  632.     void (*read_inode) (struct inode *);
  633.     void (*write_inode) (struct inode *);
  634.     void (*put_inode) (struct inode *);
  635.     void (*delete_inode) (struct inode *);
  636.     int (*notify_change) (struct dentry *, struct iattr *);
  637.     void (*put_super) (struct super_block *);
  638.     void (*write_super) (struct super_block *);
  639.     int (*statfs) (struct super_block *, struct statfs *, int);
  640.     int (*remount_fs) (struct super_block *, int *, char *);
  641.     void (*clear_inode) (struct inode *);
  642.     void (*umount_begin) (struct super_block *);
  643. };
  644.  
  645. struct dquot_operations {
  646.     void (*initialize) (struct inode *, short);
  647.     void (*drop) (struct inode *);
  648.     int (*alloc_block) (const struct inode *, unsigned long, uid_t, char);
  649.     int (*alloc_inode) (const struct inode *, unsigned long, uid_t);
  650.     void (*free_block) (const struct inode *, unsigned long);
  651.     void (*free_inode) (const struct inode *, unsigned long);
  652.     int (*transfer) (struct inode *, struct iattr *, char, uid_t);
  653. };
  654.  
  655. struct file_system_type {
  656.     const char *name;
  657.     int fs_flags;
  658.     struct super_block *(*read_super) (struct super_block *, void *, int);
  659.     struct file_system_type * next;
  660. };
  661.  
  662. extern int register_filesystem(struct file_system_type *);
  663. extern int unregister_filesystem(struct file_system_type *);
  664.  
  665.  
  666. #define FLOCK_VERIFY_READ  1
  667. #define FLOCK_VERIFY_WRITE 2
  668.  
  669. extern int locks_mandatory_locked(struct inode *inode);
  670. extern int locks_mandatory_area(int read_write, struct inode *inode,
  671.                 struct file *filp, loff_t offset,
  672.                 size_t count);
  673.  
  674. extern inline int locks_verify_locked(struct inode *inode)
  675. {
  676.     /* Candidates for mandatory locking have the setgid bit set
  677.      * but no group execute bit -  an otherwise meaningless combination.
  678.      */
  679.     if (IS_MANDLOCK(inode) &&
  680.         (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
  681.         return (locks_mandatory_locked(inode));
  682.     return (0);
  683. }
  684.  
  685. extern inline int locks_verify_area(int read_write, struct inode *inode,
  686.                     struct file *filp, loff_t offset,
  687.                     size_t count)
  688. {
  689.     /* Candidates for mandatory locking have the setgid bit set
  690.      * but no group execute bit -  an otherwise meaningless combination.
  691.      */
  692.     if (IS_MANDLOCK(inode) &&
  693.         (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
  694.         return (locks_mandatory_area(read_write, inode, filp, offset,
  695.                          count));
  696.     return (0);
  697. }
  698.  
  699.  
  700. /* fs/open.c */
  701.  
  702. asmlinkage int sys_open(const char *, int, int);
  703. asmlinkage int sys_close(unsigned int);        /* yes, it's really unsigned */
  704. extern int do_truncate(struct dentry *, unsigned long);
  705. extern int get_unused_fd(void);
  706. extern void put_unused_fd(unsigned int);
  707.  
  708. extern struct file *filp_open(const char *, int, int);
  709. extern int filp_close(struct file *, fl_owner_t id);
  710.  
  711. extern char * getname(const char * filename);
  712. #define __getname()    ((char *) __get_free_page(GFP_KERNEL))
  713. #define putname(name)    free_page((unsigned long)(name))
  714.  
  715. extern void kill_fasync(struct fasync_struct *fa, int sig);
  716. extern int register_blkdev(unsigned int, const char *, struct file_operations *);
  717. extern int unregister_blkdev(unsigned int major, const char * name);
  718. extern int blkdev_open(struct inode * inode, struct file * filp);
  719. extern int blkdev_release (struct inode * inode);
  720. extern struct file_operations def_blk_fops;
  721. extern struct inode_operations blkdev_inode_operations;
  722.  
  723. /* fs/devices.c */
  724. extern int register_chrdev(unsigned int, const char *, struct file_operations *);
  725. extern int unregister_chrdev(unsigned int major, const char * name);
  726. extern int chrdev_open(struct inode * inode, struct file * filp);
  727. extern struct file_operations def_chr_fops;
  728. extern struct inode_operations chrdev_inode_operations;
  729. extern char * bdevname(kdev_t dev);
  730. extern char * cdevname(kdev_t dev);
  731. extern char * kdevname(kdev_t dev);
  732.  
  733.  
  734. extern void init_fifo(struct inode * inode);
  735. extern struct inode_operations fifo_inode_operations;
  736.  
  737. /* Invalid inode operations -- fs/bad_inode.c */
  738. extern void make_bad_inode(struct inode * inode);
  739. extern int is_bad_inode(struct inode * inode);
  740.  
  741. extern struct file_operations connecting_fifo_fops;
  742. extern struct file_operations read_fifo_fops;
  743. extern struct file_operations write_fifo_fops;
  744. extern struct file_operations rdwr_fifo_fops;
  745. extern struct file_operations read_pipe_fops;
  746. extern struct file_operations write_pipe_fops;
  747. extern struct file_operations rdwr_pipe_fops;
  748.  
  749. extern struct file_system_type *get_fs_type(const char *name);
  750.  
  751. extern int fs_may_remount_ro(struct super_block *);
  752. extern int fs_may_mount(kdev_t dev);
  753.  
  754. extern struct file *inuse_filps;
  755.  
  756. extern void refile_buffer(struct buffer_head * buf);
  757. extern void set_writetime(struct buffer_head * buf, int flag);
  758. extern int try_to_free_buffers(struct page *);
  759.  
  760. extern int nr_buffers;
  761. extern int buffermem;
  762. extern int nr_buffer_heads;
  763.  
  764. #define BUF_CLEAN    0
  765. #define BUF_LOCKED    1    /* Buffers scheduled for write */
  766. #define BUF_DIRTY    2    /* Dirty buffers, not yet scheduled for write */
  767. #define NR_LIST        3
  768.  
  769. void mark_buffer_uptodate(struct buffer_head * bh, int on);
  770.  
  771. extern inline void mark_buffer_clean(struct buffer_head * bh)
  772. {
  773.     if (test_and_clear_bit(BH_Dirty, &bh->b_state)) {
  774.         if (bh->b_list == BUF_DIRTY)
  775.             refile_buffer(bh);
  776.     }
  777. }
  778.  
  779. extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag)
  780. {
  781.     if (!test_and_set_bit(BH_Dirty, &bh->b_state)) {
  782.         set_writetime(bh, flag);
  783.         if (bh->b_list != BUF_DIRTY)
  784.             refile_buffer(bh);
  785.     }
  786. }
  787.  
  788. extern int check_disk_change(kdev_t dev);
  789. extern int invalidate_inodes(struct super_block * sb);
  790. extern void invalidate_inode_pages(struct inode *);
  791. extern void invalidate_buffers(kdev_t dev);
  792. extern int floppy_is_wp(int minor);
  793. extern void sync_inodes(kdev_t dev);
  794. extern void write_inode_now(struct inode *inode);
  795. extern void sync_dev(kdev_t dev);
  796. extern int fsync_dev(kdev_t dev);
  797. extern void sync_supers(kdev_t dev);
  798. extern int bmap(struct inode * inode,int block);
  799. extern int notify_change(struct dentry *, struct iattr *);
  800. extern int permission(struct inode * inode,int mask);
  801. extern int get_write_access(struct inode *inode);
  802. extern void put_write_access(struct inode *inode);
  803. extern struct dentry * open_namei(const char * pathname, int flag, int mode);
  804. extern struct dentry * do_mknod(const char * filename, int mode, dev_t dev);
  805. extern int do_pipe(int *);
  806.  
  807. /* fs/dcache.c -- generic fs support functions */
  808. extern int is_subdir(struct dentry *, struct dentry *);
  809. extern ino_t find_inode_number(struct dentry *, struct qstr *);
  810.  
  811. /*
  812.  * Kernel pointers have redundant information, so we can use a
  813.  * scheme where we can return either an error code or a dentry
  814.  * pointer with the same return value.
  815.  *
  816.  * This should be a per-architecture thing, to allow different
  817.  * error and pointer decisions.
  818.  */
  819. #define ERR_PTR(err)    ((void *)((long)(err)))
  820. #define PTR_ERR(ptr)    ((long)(ptr))
  821. #define IS_ERR(ptr)    ((unsigned long)(ptr) > (unsigned long)(-1000))
  822.  
  823. extern struct dentry * lookup_dentry(const char *, struct dentry *, unsigned int);
  824. extern struct dentry * __namei(const char *, unsigned int);
  825.  
  826. #define namei(pathname)        __namei(pathname, 1)
  827. #define lnamei(pathname)    __namei(pathname, 0)
  828.  
  829. extern void iput(struct inode *);
  830. extern struct inode * iget(struct super_block *, unsigned long);
  831. extern void clear_inode(struct inode *);
  832. extern struct inode * get_empty_inode(void);
  833.  
  834. extern void insert_inode_hash(struct inode *);
  835. extern void remove_inode_hash(struct inode *);
  836. extern struct file * get_empty_filp(void);
  837. extern struct buffer_head * get_hash_table(kdev_t, int, int);
  838. extern struct buffer_head * getblk(kdev_t, int, int);
  839. extern struct buffer_head * find_buffer(kdev_t dev, int block, int size);
  840. extern void ll_rw_block(int, int, struct buffer_head * bh[]);
  841. extern int is_read_only(kdev_t);
  842. extern void __brelse(struct buffer_head *);
  843. extern inline void brelse(struct buffer_head *buf)
  844. {
  845.     if (buf)
  846.         __brelse(buf);
  847. }
  848. extern void __bforget(struct buffer_head *buf);
  849. extern inline void bforget(struct buffer_head *buf)
  850. {
  851.     if (buf)
  852.         __bforget(buf);
  853. }
  854. extern void set_blocksize(kdev_t dev, int size);
  855. extern unsigned int get_hardblocksize(kdev_t dev);
  856. extern struct buffer_head * bread(kdev_t dev, int block, int size);
  857. extern struct buffer_head * breada(kdev_t dev,int block, int size, 
  858.                    unsigned int pos, unsigned int filesize);
  859.  
  860. extern int brw_page(int, struct page *, kdev_t, int [], int, int);
  861.  
  862. extern int generic_readpage(struct file *, struct page *);
  863. extern int generic_file_mmap(struct file *, struct vm_area_struct *);
  864. extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
  865. extern ssize_t generic_file_write(struct file *, const char*, size_t, loff_t*);
  866.  
  867. extern struct super_block *get_super(kdev_t dev);
  868. extern void put_super(kdev_t dev);
  869. unsigned long generate_cluster(kdev_t dev, int b[], int size);
  870. unsigned long generate_cluster_swab32(kdev_t dev, int b[], int size);
  871. extern kdev_t ROOT_DEV;
  872.  
  873. extern void show_buffers(void);
  874. extern void mount_root(void);
  875.  
  876. #ifdef CONFIG_BLK_DEV_INITRD
  877. extern kdev_t real_root_dev;
  878. extern int change_root(kdev_t new_root_dev,const char *put_old);
  879. #endif
  880.  
  881. extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
  882. extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
  883. extern int read_ahead[];
  884.  
  885. extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
  886. extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
  887.  
  888. extern int block_fsync(struct file *, struct dentry *dir);
  889. extern int file_fsync(struct file *, struct dentry *dir);
  890.  
  891. extern int inode_change_ok(struct inode *, struct iattr *);
  892. extern void inode_setattr(struct inode *, struct iattr *);
  893.  
  894. /* kludge to get SCSI modules working */
  895. #include <linux/minix_fs.h>
  896. #include <linux/minix_fs_sb.h>
  897.  
  898. #endif /* __KERNEL__ */
  899.  
  900. #endif
  901.